package com.rj1101.hscrm.demo.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.rj1101.hscrm.demo.dao.AppointmentinfoDAO;
import com.rj1101.hscrm.demo.model.Appointmentinfo;
import com.rj1101.hscrm.demo.model.Emp;
import com.rj1101.hscrm.demo.model.Treatment;
import com.rj1101.hscrm.demo.service.AppointmentService;
import com.rj1101.hscrm.demo.util.Paging;

public class AppointmentServiceImpl implements AppointmentService {

	private AppointmentinfoDAO appDao;
	
	
	public void setAppDao(AppointmentinfoDAO appDao) {
		this.appDao = appDao;
	}

	public boolean addAppoitment(Appointmentinfo appointment) {
		boolean s=false;
		try {
			appDao.save(appointment);
			s=true;
		} catch (Exception e) {
			// TODO: handle exception
			s=false;
		}
		// TODO Auto-generated method stub
		return s;
	}

	public boolean alterAppointment(Appointmentinfo appoitment) {
		// TODO Auto-generated method stub
		boolean s=false;
		try {
			appDao.attachDirty(appoitment);
			s=true;
		} catch (Exception e) {
			// TODO: handle exception
			s=false;
		}
		return s;
	}

	public boolean delAppointment(Appointmentinfo appoitment) {
		// TODO Auto-generated method stub
		boolean s=false;
		try {
			appDao.delete(appoitment);
			s=true;
		} catch (Exception e) {
			// TODO: handle exception
			s=false;
		}
		return s;
	}

	public Appointmentinfo findByAppointId(int appointId) {
		// TODO Auto-generated method stub
		return appDao.findById(appointId);
	}

	public List<Appointmentinfo> findByDate(String start, String end) {
		
		return appDao.findByAppointDateTime(start,end);
	}

	public List<Appointmentinfo> findByCustomerId(int customerId) {
		// TODO Auto-generated method stub
		return appDao.findByAppointCustomer(customerId);
	}

	public List<Appointmentinfo> findByCustomerName(String name) {
		// TODO Auto-generated method stub
		return appDao.findByAppointCustomer(name);
	}

	public List<Appointmentinfo> findByCardId(String cardId) {
		// TODO Auto-generated method stub
		return appDao.findByAppointCustomer(cardId);
	}

	public List<Appointmentinfo> findByDoctor(String doctor) {
		// TODO Auto-generated method stub
		return appDao.findByAppointDoctor(doctor);
	}

	public List<Appointmentinfo> findAllAppInfo() {
		// TODO Auto-generated method stub
		
		return appDao.findAll();
	}

	public List<Appointmentinfo> pagingAppointInfo(String string,
			Paging pager) {
		// TODO Auto-generated method stub
		return appDao.pagingAppointInfo(string, pager);
	}


}
